package cn.witsky.rtp2ws.domain;

import java.io.Serializable;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import cn.witsky.rtp2ws.util.SystemClock;

public class Message implements Serializable,Cloneable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 6403179433602270986L;
	private static Logger logger = LoggerFactory.getLogger(Message.class);
	private int index;
	private boolean isCaller;
	private String callId;
	private int seq;
	private byte[] bytes = null;
	private long currentTimeMillis = -1;

	public Message(boolean isCaller) {
		this.isCaller = isCaller;
		currentTimeMillis = SystemClock.now();
	}

	public Message() {
	}

	public void setCurrentTimeMillis(long currentTimeMillis) {
		this.currentTimeMillis = currentTimeMillis;
	}

	public boolean isCaller() {
		return isCaller;
	}

	public void setCaller(boolean isCaller) {
		this.isCaller = isCaller;
	}

	public String getCallId() {
		return callId;
	}

	public void setCallId(String callId) {
		this.callId = callId;
	}

	public int getSeq() {
		return seq;
	}

	public void setSeq(int seq) {
		this.seq = seq;
	}

	public byte[] getBytes() {
		return bytes;
	}

	public void setBytes(byte[] bytes) {
		this.bytes = bytes;
	}


	public long getCurrentTimeMillis() {
		return currentTimeMillis;
	}

	public int getIndex() {
		return index;
	}

	public void setIndex(int index) {
		this.index = index;
	}

	public Object clone() {
		Message o = null;
		try {
			o = (Message) super.clone();
			o.index=this.index;
			o.seq=this.seq;
			o.isCaller=this.isCaller;
			o.bytes=this.bytes.clone();
			o.callId=this.callId;
			o.currentTimeMillis=this.currentTimeMillis;
		} catch (CloneNotSupportedException e) {
			logger.error("克隆出现异常:",e);
		}
		return o;
	}

	@Override
	public String toString() {
		return "Message [index=" + index + ", isCaller=" + isCaller + ", callId=" + callId + ", seq=" + seq
				+ ", currentTimeMillis=" + currentTimeMillis + "byte长度:"+bytes.length+"]";
	}

	
	

}
